/****************************************************************************
**
** Copyright (C) 2012 Róbert Márki
**
** This file is part of Web Feeds.
**
** Web Feeds is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Web Feeds is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Web Feeds.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

import QtQuick 1.1
import com.nokia.meego 1.0
import com.nokia.extras 1.1
import "../../../../shared/qml/UIConstants.js" as UIConstants

Item {
    id: root
    property Dialog dialogItem
    property alias labelText: nameLabel.text
    property alias text: contentLabel.text
    property alias status: selectionDialog.status
    property alias model: selectionDialog.model
    property alias selectedIndex: selectionDialog.selectedIndex
    signal accepted
    signal rejected
    height: UIConstants.LIST_ITEM_HEIGHT_SMALL
    width: parent.width

    Connections {
        target: selectionDialog
        onAccepted: root.accepted();
        onRejected: root.rejected();
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: {
            selectionDialog.open();
        }
    }

    BorderImage {
        id: background
        anchors.fill: parent
        // Fill page porders
        anchors.leftMargin: -UIConstants.MARGIN_XLARGE
        anchors.rightMargin: -UIConstants.MARGIN_XLARGE
        visible: mouseArea.pressed
        source: "image://theme/meegotouch-list-background-pressed-center"
    }

    Image {
        id: tumblerIcon
        anchors.right: parent.right
        anchors.rightMargin: UIConstants.DEFAULT_MARGIN
        anchors.verticalCenter: parent.verticalCenter
        source: "image://theme/meegotouch-combobox-indicator" +
                (mouseArea.pressed ? "-pressed" : "")
    }
    Column {
        anchors.fill: parent
        width: parent.width
        Label {
            id: nameLabel
            font.bold: true
        }
        Label {
            id: contentLabel
            text: (root.selectedIndex != -1) ? root.model.get(root.selectedIndex).name : "empty"
        }
    }
    SelectionDialog {
        id: selectionDialog
        titleText: root.labelText
    }
}
